from tools_algorithm import *


class Solution:
    def minimumDeletions(self, word: str, k: int) -> int:
        cnt = Counter(word)
        cnt[0] = 0
        # ks = sorted(cnt.keys(), key=lambda a: cnt[a])
        ans = inf
        for _, v in cnt.items():
            d = 0
            for _, v1 in cnt.items():
                if v1 < v:
                    d += v1
                elif v1 > v + k:
                    d += v1 - v - k
            ans = min(d, ans)
        return ans


a = [1, 1, 1, 1]
print(list(accumulate(a, initial=0)))
